#pragma once

#include "GameObject.h"
#include "EventSet.h"
#include "EventParamsImp.h"
#include "Player.h"

struct CellPair
{
	CellPair(int fx = 0, int fy = 0) : x(fx),y(fy){}
	bool operator==(const CellPair& p)
	{
		return x=p.x && y==p.y;
	}

	int x;
	int y;
};

class Cell : public EventSet
{
public:
	Cell(void);
	~Cell(void);

	void addObject(WorldObject* obj)
	{
		m_objects.insert( obj );
	}

	void removeObject(WorldObject* obj)
	{
		m_objects.erase(obj);
	}

	void addPlayer(Player* obj)
	{
		addObject( obj );
		m_players.insert(obj);
	}

	void removePlayer(Player* obj)
	{
		removeObject(obj);
		m_players.erase(obj);
	}

	size_t size() const
	{
		return m_objects.size();
	}


	typedef std::set<WorldObject*>::iterator iterator;

	std::set<WorldObject*>::iterator begin()
	{
		return m_objects.begin();
	}

	std::set<WorldObject*>::iterator end()
	{
		return m_objects.end();
	}

	typedef std::set<Player*>::iterator player_iterator;

	std::set<Player*>::iterator player_begin()
	{
		return m_players.begin();
	}

	std::set<Player*>::iterator player_end()
	{
		return m_players.end();
	}

private:

	std::set<WorldObject*> m_objects;
	std::set<Player*> m_players;
};
